package com.xperblueray.stepbystep.consumer;

import com.xperblueray.stepbystep.model.SbsMood;
import com.xperblueray.stepbystep.service.SbsMoodService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class SbsMoodConsumer {
    Logger logger = LogManager.getLogger(this.getClass());

    @Resource
    SbsMoodService sbsMoodService;
    // 使用JmsListener配置消费之监听的队列sbs.queue，其中text是接收到的消息
    @JmsListener(destination = "sbs.queue")
    public void reciveQueue(String text) {
       logger.info("用户发表说说【" + text + "】");
    }

    @JmsListener(destination = "sbs.queue.asyn.save")
    public void reciveQueue(SbsMood sbsMood) {
        sbsMoodService.save(sbsMood);
    }
}
